package com.zhxy.utils;

import lombok.Data;

/**
 * 封装后台返回的数据信息
 */
@Data
public class Result {
    //111
    //2222
    private Integer code;//状态码
    private String message;//提示信息
    private Object data;//封装的查询功能的数据

    /**
     * 增、删、改功能的封装信息
     * @param code
     * @param message
     */
    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 查询封装的信息
     * @param code
     * @param message
     * @param data
     */
    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static Result ok(Object data){
        return new Result(StatusCode.SUCCESS,"ok",data);
    }
    public static Result ok(String message){
        return new Result(StatusCode.SUCCESS,message);
    }
    public static Result ok(Object data,String message){
        return new Result(StatusCode.SUCCESS,message,data);
    }
    public static Result fail(String message){
        return new Result(StatusCode.ERROR,message);
    }

}
